<template>
	<view>
		<view class="mainView">
			<view v-for="(item,index) in list" :key="index" >
				<view class="cell">
					<view class="noticetime">
						<view>{{item.notice}}</view>
						<view>{{item.time}}</view>
					</view>
					<view :class="'record '+ (item.record>0?'add':'sub')">
						<label v-if="item.record>0">+</label>{{item.record}}
					</view>
				</view>
				<view v-if="index<list.length-1" class="br"></view>
			</view>
			<view v-if="list.length==20" style="margin-top: 10rpx; color: #999999; text-align: center;">仅显示20条记录哦</view>
		</view>
		<view class="safeView"></view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				list:[]
			}
		},
		onLoad(){
			const that=this;
			wx.showLoading();
			wx.request({
				url:this.myConfig.hostUrl+'/api/scoreRecord.php',
				method:'POST',
				data:{
					openId:that.myConfig.openId
				},
				success:function(res){
					console.log('list',res.data.scoreRecord);
					if(res.data.errCode==200){
						wx.hideLoading();
						for(let i=0;i<res.data.scoreRecord.length;i++){
							res.data.scoreRecord[i].time=that.myConfig.tansf(res.data.scoreRecord[i].time);
						}
						that.list=res.data.scoreRecord;
					}else{
						wx.hideLoading();
						uni.showToast({
							title:'网络好像不太好欸',
							icon:'none',
							duration:1200
						});
					}
				},
				fail:function(){
					wx.hideLoading();
					uni.showToast({
						title:'网络好像不太好欸',
						icon:'none',
						duration:1200
					});
				}
			})
		}
	}
</script>

<style scoped>
	.mainView{
		margin: 25rpx;
	}
	.cell{
		width: 90%;
		padding-left: 5%;
		padding-right: 5%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 40rpx;
		font-weight: 700;
		color: #888888;
		margin-top: 10rpx;
	}
	.add{
		color: #4CD96E;
	}
	.sub{
		color: #DD523F;
	}
	.br{
		width: 100%;
		height: 2rpx;
		background:-webkit-linear-gradient(0deg, #ffffff, #888888, #ffffff);
	}
</style>
